#pragma once

#include <iostream>
#include <cstdio>
#include <cstdarg>
#include <ctime>
#include <string>

#define DEBUG   0
#define NORMAL  1
#define WARNING 2
#define ERROR   3
#define FATAL   4

const char *gLevelMap[] =
{
    "DEBUG",
    "NORMAL",
    "WARNING",
    "ERROR",
    "FATAL"
};

void logMessage(int level, const char* fmt, ...)
{
    char stdBuffer[1024];
    time_t timestamp=time(nullptr);
    snprintf(stdBuffer, sizeof(stdBuffer), "[%s] [%lld]", gLevelMap[level], timestamp);

    char logBuffer[1024];
    va_list args;
    va_start(args, fmt);
    vsnprintf(logBuffer, sizeof(logBuffer), fmt, args);
    va_end(args);

    printf("%s %s\n", stdBuffer, logBuffer);
}